// 重定向页面 - 将/pages/recipe/detail/重定向到/pages/discover/recipe/detail/
Page({
  onLoad(options) {
    console.log('收到参数:', options);
    const recipeId = options.id;
    
    if (recipeId) {
      // 构建新的URL，保留所有参数
      let params = [];
      for (let key in options) {
        params.push(`${key}=${options[key]}`);
      }
      const queryString = params.join('&');
      
      // 重定向到正确的详情页
      wx.redirectTo({
        url: `/pages/discover/recipe/detail/index?${queryString}`
      });
    } else {
      wx.showToast({
        title: '缺少菜谱ID参数',
        icon: 'none',
        duration: 2000
      });
      setTimeout(() => {
        wx.navigateBack();
      }, 2000);
    }
  }
}) 